# coding = utf-8

import unittest
from xd_api_test.util.request_util import RequestUtil

host = "https://api-v2.xdclass.net"


class IndexTestCase(unittest.TestCase):

    def testIndexCategoryList(self):
        """
        热门课程列表
        """
        request = RequestUtil()
        url = host + "/api/card/v1/list"
        response = request.request(url, 'get')

        self.assertEqual(response['code'], 0, "业务状态不正常")

        self.assertTrue(len(response['data']) > 0, "热门课程分类列表为空")

    def testIndexVideoCard(self):
        """
        首页视频卡片
        """
        request = RequestUtil()
        url = host + "/api/page_item/v1/list?type=HOME_CATEGORY_BOTTOM"
        response = request.request(url, 'get')

        self.assertEqual(response['code'], 0, "业务状态不正常")
        self.assertTrue(len(response['data']) > 0, "视频卡片为空")

        video_card_list = response['data']
        for card in video_card_list:
            self.assertTrue(len(card['title']) > 0, "卡片标题为空 id=" + str(card['id']))


if __name__ == '__main__':
    unittest.main(verbosity=2)
